package zengqiang.day02

//kotlin中所有运算符本质上都是方法，可以ctrl跳转看看
fun main(args: Array<String>) {
    var a = 10
    var b = 10
    println(a + b)//就相当于a.plus(b)

    var g1 = Girl()
    var g2 = Girl()
    println(g1 + g2)//24  相当于g1.plus(g2)
}

//运算符重载案例,注意一定要加上operator，不然plus还是普通函数
class Girl {
    var age: Int = 12
    var name: String = "张三"
    operator fun plus(girl: Girl): Int {
        return this.age + girl.age
    }
}